(ns acst.main
  (:require [ring.adapter.jetty :refer [run-jetty]]
            [ring.middleware.reload :refer [wrap-reload]]
            [org.httpkit.server :refer [run-server]]
            [selmer.parser :refer [set-resource-path!]]
            [acst.handler :refer [app]]
            [clojure.data.json :as json])
  (:gen-class))

(def in-dev? true)

;(extend-protocol Integer
;  compojure.response/Renderable
;  (render [this _]
;    (json/write-str {:int this})))

(extend-type java.sql.Timestamp
  json/JSONWriter
  (-write [date out]
    (json/-write (str date) out)))

(defn -main [& args]
  (set-resource-path! (clojure.java.io/resource "templates"))
  (let [handler (if in-dev? (wrap-reload app) app)]
    (run-server handler {:port 8080})))

